Skip to content

[Accuracy diff No.137] Fix accuracy diff for paddle.scatter API - #302

Merged
cangtianhuang merged 2 commits into
PFCCLab:mainfrom
ooooo-create:accuracy_scatter
Jun 20, 2025
Merged

cangtianhuang merged 2 commits into
PFCCLab:mainfrom
ooooo-create:accuracy_scatter

Conversation

@ooooo-create

@ooooo-create ooooo-create commented Jun 19, 2025 •

Copy link
Copy Markdown
Contributor

move special scatter config to random_calculation
paddle.scatter(Tensor([183826, 256],"float32"), Tensor([10759233],"int64"), Tensor([10759233, 256],"float32"), )
the index 10759233 is greater than x.shape[0] 183826, can't generate unique index, overwrite default is True, so the result is random_calculation

elif api_config.api_name == "paddle.scatter":
if key == "index" or index == 1:
d=self.get_arg(api_config, 0, "x")
s=d.shape[0]
overwrite = self.get_arg(api_config, 3, "overwrite")
if ( overwrite == None or overwrite == True ) and ( self.shape == [] or self.shape[0] ) <=s :
self.numpy_tensor = numpy.random.choice(s, size=self.shape, replace=False).astype(self.dtype)
else:
self.numpy_tensor = numpy.random.randint(0, s, size=self.shape).astype(self.dtype)

@paddle-bot

paddle-bot Bot commented Jun 19, 2025

Copy link
Copy Markdown

Thanks for your contribution!

@cangtianhuang cangtianhuang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very detailed, LGTM!

@cangtianhuang
cangtianhuang merged commit a6ee176 into PFCCLab:main Jun 20, 2025
@ooooo-create
ooooo-create deleted the accuracy_scatter branch September 29, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants